#include <iostream>
#include <vector>
using namespace std;

int main() {

	int n;
	string str;
	cin>>n>>str;
	vector<char> f;
	for(int i=0;i<static_cast<int>(str.size());++i){
		int left=0,right=f.size()-1;
		while(left<right){
			int mid=left+(right-left)/2;
			if(f[mid]>str[i]){
				right=mid;
			}
			else{
				left=mid+1;
			}
		}
		if(f.size() && f[left]>str[i]){
			
			f[left]=str[i];
		}
		else{
			f.push_back(str[i]);
		}
	}
	cout<<n-f.size()<<endl;
	
	return 0;
}
